//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#pragma package(smart_init)
#include "CHistorique.h"
//---------------------------------------------------------------------------

char * txtHIST_EVEN[] =	{

    "Ajout d'un logiciel",
    "Duplication logiciel",
    "Suppression logiciel",

    "Ajout d'une version",
    "Duplication version",
    "Suppression version",

    "Ajout d'une référence",
    "Modification d'une référence",
    "Duplication d'une référence",
    "Suppression d'une référence",
    "Suppression d'une page Web",

    "Mise à jour des bases",
    "Création de référence auto"
};

//---------------------------------------------------------------------------
//                          Constructeur
//---------------------------------------------------------------------------
__fastcall CHistorique::CHistorique()
{
    char * sUserName = NULL;
    try {
        m_Time = TDateTime::CurrentDateTime();
        sUserName = new char[50+1];
        DWORD d = 51;
        m_asUserName = EmptyStr;

        if( GetUserName( sUserName, &d ) )
            m_asUserName = AnsiString(sUserName);
        else
            m_asUserName = "invité";
    }catch( Exception &e ) {
        EIC_DISPLAY_EXCEPTION(e);}
    if(sUserName) {delete [] sUserName; sUserName = NULL;}
}
//---------------------------------------------------------------------------
//      Ajouter
//---------------------------------------------------------------------------
void __fastcall CHistorique::AjouterOperation( THistorique nOpe,
                                               const AnsiString &asLog,
                                               const AnsiString &asVer,
                                               const AnsiString &asRef,
                                               const AnsiString &asDesignation,
                                               const AnsiString &asPageWeb)
{
    TdmWebHelp * dmWebHelp = NULL;
    try {
        AnsiString asTypeOperation = txtHIST_EVEN[nOpe];

        dmWebHelp = new TdmWebHelp((TComponent*)0);
        dmWebHelp->tHisto->Active = true;
        dmWebHelp->tHisto->Insert();
        astHisto(HISTO_NOM)             =      m_asUserName;
        dttHisto(HISTO_TIME)            =      m_Time.FormatString("hh:nn:ss");
        dttHisto(HISTO_DATE)            =      m_Time.FormatString("dd/mm/yyyy");
        astHisto(HISTO_OPERATION)       =      asTypeOperation;

        astHisto(HISTO_LOG)             =      asLog;
        astHisto(HISTO_VER)             =      asVer;
        astHisto(HISTO_REF)             =      asRef;
        astHisto(HISTO_REF_SOUS_NOM)    =      asDesignation;
        astHisto(HISTO_PAGEWEB)         =      asPageWeb;
        
        dmWebHelp->tHisto->Post();
        dmWebHelp->trWebHelp->Commit();
    }catch( Exception &e ) {
        EIC_DISPLAY_EXCEPTION(e);}
    if(dmWebHelp) {delete dmWebHelp; dmWebHelp = NULL;}
}
//---------------------------------------------------------------------------
 